package com.dlb.andorid.presenter;

import com.dlb.andorid.XAPI;
import com.dlb.andorid.XContract;
import com.dlb.andorid.XPresenter;
import com.dlb.andorid.XServerMsg;
import com.dlb.andorid.bean.OrderBean;
import com.dlb.andorid.bean.OrderInfo;

import java.util.HashMap;
import java.util.List;

public class OrderListPresenter extends XPresenter {

	XContract.IOrderView iView;

	public OrderListPresenter(XContract.IOrderView iView) {
		super(iView);
		this.iView = iView;
	}

	public void getOrderList(int type) {
		mModel.getOrderList(type);
	}

	public void delOrder(long orderId, String orderNo, int index) {
		mModel.delOrderList(orderId, orderNo, index);
	}

	public void getOrderInfo( String orderNo) {
		mModel.getOrderInfo( orderNo);
	}

	public void tkOrder(long orderId, String orderNo, int index) {
		mModel.tkOrder(orderId, orderNo, index);
	}

	public void pjOrder(long orderId, String orderNo, int index) {
		mModel.pjOrder(orderId, orderNo, index);
	}


	@Override
	public void onDataSuccess(int vocational_id, HashMap<String, Object> exData, Object data) {
		super.onDataSuccess(vocational_id, exData, data);
		switch (vocational_id) {
			case XAPI.GET_ORDER_LIST:
				iView.getOrderListSuccess(((XServerMsg<List<OrderBean>>) data).getData(), (Integer) exData.get("type"));
				break;
			case XAPI.DELTE_OEDER_VOCATIONAL_ID:
				iView.delOrderSuccess((XServerMsg) data, (Integer) exData.get("index"));
				break;
			case XAPI.GET_ORDER_INFO_VOCATIONAL_ID:
				iView.getOrderInfoSuccess((XServerMsg<OrderInfo>) data);
				break;
			case XAPI.TK_ORDER_VOCATIONAL_ID:
				iView.tkOrderSuccess((XServerMsg) data, (Integer) exData.get("index"));
				break;
			case XAPI.PJ_ORDER_VOCATIONAL_ID:
				iView.pjOrderSuccess((XServerMsg) data, (Integer) exData.get("index"));
				break;
		}
	}
}
